﻿@using ACGN.MVC.Models.Newsflashss;
@model NewsflashViewModel
<div class="x-body">
	<form class="layui-form layui-form-pane" id="frmAdd">
		<div class="layui-form layuimini-form" style="border:1px dashed;margin:50px 50px 50px 50px;padding-top:20px;">
			<input type="hidden" asp-for="NFId" />
			@*<input type="hidden" asp-for="ClassId" />*@
			<div class="layui-form-item">
				<label class="layui-form-label" asp-for="NFName">
				</label>
				<div class="layui-input-block">
					<input type="text" asp-for="NFName" required lay-verify="title" autocomplete="off" class="layui-input">
					<span asp-validation-for="NFName" style="color: #F56C6C"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" asp-for="NfTypeId">
				</label>
				<div class="layui-input-block">
					<select asp-for="NfTypeId" asp-items="@ViewBag.NfTypeList"></select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" asp-for="NFContent">
				</label>
				<div class="layui-input-block">
					<input type="text" asp-for="NFContent" required lay-verify="title" autocomplete="off" class="layui-input">
					<span asp-validation-for="NFContent" style="color: #F56C6C"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<button class="layui-btn" lay-filter="add" lay-submit>
					保存
				</button>
			</div>
			</div>
	</form>
</div>
@section Scripts{
    <script>
        layui.use(['form', 'layer', 'layedit'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit;
            //监听提交事件sumbmit,*表示那个提交按钮，过滤器名
            form.on('submit(add)', function (data) {
                var str = $("#frmAdd").serialize();//表单序列化
                console.log(str);
                //$.post(地址,向服务器传的参数,回调函数,返回值类型)
                $.post("/Admin/NewsFlash/EditNews", str, function (re) {
                    parent.layer.msg("修改成功");//parent父窗体
                    parent.layui.$("#btnSearch").click();//调用你窗体中的查询按钮的单击事件实现，数据刷新
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }, "text");
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });

        });
    </script>

}
